<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>大事件-发布文章</title>
    <link rel="stylesheet" href="/assets/lib/layui/css/layui.css" />
    <link rel="stylesheet" href="/assets/lib/cropper/cropper.css" />
    <style>
      * {
        margin: 0;
        padding: 0;
      }
      body {
        background-color: #edebeb;
        padding: 20px;
      }
      /* 封面容器的样式 */
      .cover-box {
        display: flex;
      }

      /* 左侧裁剪区域的样式 */
      .cover-left {
        width: 400px;
        height: 280px;
        overflow: hidden;
        margin-right: 20px;
      }

      /* 右侧盒子的样式 */
      .cover-right {
        display: flex;
        flex-direction: column;
        align-items: center;
      }

      /* 预览区域的样式 */
      .img-preview {
        width: 200px;
        height: 140px;
        background-color: #ccc;
        margin-bottom: 20px;
        overflow: hidden;
      }
    </style>
  </head>
  <body>
    <div class="layui-card">
      <div class="layui-card-header">发布文章</div>
      <div class="layui-card-body">
        <!-- 放置表单 -->
        <form id="myForm" class="layui-form" lay-filter="formData">
          <!-- 隐藏域 虽然看不到它 他能接受数据 获取的时候 数据也能取出来 -->
          <!-- 提交时要取id -->
          <div class="layui-form-item">
            <label class="layui-form-label">文章标题</label>
            <div class="layui-input-block">
              <input
                name="title"
                required
                lay-verify="required"
                autocomplete="off"
                class="layui-input"
                placeholder="请输入文章标题"
              />
            </div>
          </div>
          <div class="layui-form-item">
            <label class="layui-form-label">文章类别</label>
            <div class="layui-input-block">
              <select name="cate_id" lay-verify="required"></select>
            </div>
          </div>
          <div class="layui-form-item">
            <!-- 杜撰- 瞎编 -->
            <label class="layui-form-label">文章内容</label>
            <div class="layui-input-block">
              <!-- 文章内容放置一个文本域 -->
              <!-- layui-不认识 被渲染成富文本编辑器的textarea -->
              <textarea name="content"></textarea>
            </div>
          </div>
          <div class="layui-form-item">
            <!-- 杜撰- 瞎编 -->
            <label class="layui-form-label">封面</label>
            <!-- 选择封面区域 -->
            <div class="layui-input-block cover-box">
              <!-- 左侧裁剪区域 -->
              <div class="cover-left">
                <img id="image" src="/assets/images/sample2.jpg" alt="" />
              </div>
              <!-- 右侧预览区域和选择封面区域 -->
              <div class="cover-right">
                <!-- 预览的区域 -->
                <div class="img-preview"></div>
                <input type="file" style="display: none" id="myFile" />
                <!-- 选择封面按钮 -->
                <button
                  id="selectFile"
                  type="button"
                  class="layui-btn layui-btn-danger"
                >
                  选择封面
                </button>
              </div>
            </div>
          </div>
          <div class="layui-form-item">
            <div class="layui-input-block">
              <button class="layui-btn" lay-submit lay-filter="formDemo">
                发布文章
              </button>
              <button
                id="btnDraft"
                lay-submit
                class="layui-btn layui-btn-primary"
              >
                存草稿
              </button>
            </div>
          </div>
        </form>
      </div>
    </div>
    <!-- 定义option的模板 -->
    <script type="text/html" id="option-temp">
      <option value="">所有分类</option>
      {{each data}}
      <option value="{{$value.Id}}">{{ $value.name }}</option>
      {{/each}}
    </script>
    <script src="/assets/lib/layui/layui.all.js"></script>
    <script src="/assets/lib/jquery.js"></script>
    <script src="/assets/lib/cropper/Cropper.js"></script>
    <script src="/assets/lib/cropper/jquery-cropper.js"></script>
    <script src="/assets/lib/tinymce/tinymce.min.js"></script>
    <script src="/assets/lib/tinymce/tinymce_setup.js"></script>
    <script src="/assets/lib/template-web.js"></script>
    <script src="/assets/js/baseAPI.js"></script>
    <script src="/assets/js/article/art_publish.js"></script>
  </body>
</html>
